import { BaseWindow } from "../../../../component/window/BaseWindow";
import { PositionItem } from "./PositionItem";
import { ObjCreate } from "../../common/ObjCreate";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { RadioButtonGroup } from "../../../../../fl/controls/RadioButtonGroup";
import { Cache } from "../../../cache/Cache";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GRadioButton } from "../../../../../com/mui/controls/GRadioButton";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { MsgManager } from "../../../manager/MsgManager";
import { GuildPositionInfo } from "../info/GuildPositionInfo";
import { Vector } from "../../../../../__AS3__/vec/Vector";
type int = number;
//class NominateWindow
    
    export  class NominateWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._postionItemVector = new Vector.<PositionItem>();
            this.init();
            return;
        }

        public init(): void
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            this.setSize(300, 280);
            this.titleHeight = 28;
            ObjCreate.createBg(17, 37, 265, 230, this);
            this._titleLabel = new GLabel();
            this._titleLabel.text = Language.getString(57225);
            this._titleLabel.width = 170;
            this._titleLabel.setStyle("textFormat", GlobalStyle.dialogTitle);
            this._titleLabel.x = 30;
            this._titleLabel.y = 12;
            this._titleLabel.mouseChildren = false;
            this._titleLabel.mouseEnabled = false;
            this._titleLabel.filters = [FilterConst.nameGlowFilter];
            this.title = this._titleLabel;
            this._tipText = new Object /* flash.text.TextField */();
            this._tipText.width = 300;
            this._tipText.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._tipText.y = 40;
            this.addChild(this._tipText);
            this._positionRadioGroup = new RadioButtonGroup("position");
            var loc1=Cache.instance.guild.getPositionData();
            loc3 = 0;
            while (loc3 < loc1.length) 
            {
                loc4 = loc1[loc3];
                loc2 = new PositionItem();
                loc2.selRadio.group = this._positionRadioGroup;
                loc2.updateByPositionInfo(loc4);
                loc2.x = 90;
                loc2.y = loc3 * 30 + 80;
                this.addChild(loc2);
                this._postionItemVector.push(loc2);
                ++loc3;
            }
            this._okBtn = new GButton();
            this._okBtn.label = Language.getString(57226);
            this._okBtn.styleName = "Button";
            this._okBtn.setSize(48, 27);
            this._okBtn.move(100, 230);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onOkBtnClickHandler);
            this.addChild(this._okBtn);
            this._cancelBtn = new GButton();
            this._cancelBtn.label = Language.getString(57227);
            this._cancelBtn.styleName = "Button";
            this._cancelBtn.setSize(48, 27);
            this._cancelBtn.move(175, 230);
            this._cancelBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCancelBtnClickHandler);
            this.addChild(this._cancelBtn);
            return;
        }

        /* internal  */onOkBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=0;
            var loc1=this._positionRadioGroup.selection as GRadioButton;
            if (loc1) 
            {
                loc2 = loc1.value as int;
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildNominate, {"toGuildPlayer": Cache.instance.guild.curSelGuildPlayer, "toPosition": loc2}));
                this.onCancelBtnClickHandler(null);
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(90312));
            }
            return;
        }

        /* internal  */onCancelBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            hide();
            return;
        }

        public updatePosition(arg1: Vector.<GuildPositionInfo>): void
        {
            var loc1=0;
            var loc2=null;
            var loc3=null;
            if (arg1) 
            {
                loc1 = 0;
                while (loc1 < arg1.length) 
                {
                    loc2 = this._postionItemVector[loc1];
                    loc3 = arg1[loc1];
                    loc2.updateByPositionInfo(loc3);
                    ++loc1;
                }
            }
            return;
        }

        public updateTip(arg1: string): void
        {
            this._tipText.htmlText = Language.getStringByParam(57228, arg1);
            return;
        }

        /* internal */ /* var */_titleLabel: GLabel;

        /* internal */ /* var */_tipText: Object /* flash.text.TextField */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_cancelBtn: GButton;

        /* internal */ /* var */_positionRadioGroup: RadioButtonGroup;

        /* internal */ /* var */_postionItemVector: Vector.<PositionItem>;
    }
